#include<bits/stdc++.h>
#define int long long
using namespace std;
int T;
int a,b;
void sol(){
    scanf("%lld %lld",&a,&b);
    if((a>=0&&b>=0)||(a<=0&&b<=0)) printf("0\n");
    else printf("%lld\n",min(abs(a+b),min(abs(a),abs(b))));
}
signed main(){
    freopen("sub.in","r",stdin);
    freopen("sub.out","w",stdout);
    scanf("%lld",&T);
    while(T--) sol();
    return 0;
}